package day02.attendClass;

import java.util.Arrays;

public class atClassAfternoon {
	public static void main(String[] args) {
		int[] a=new int [3];
		a[0]=1;
		a[1]=2;
		a[2]=3;
		System.out.println(a.length);
		for(int c:a) {
			System.out.print(c);
			
		}
		int max=0;
		for(int c:a) {
//			System.out.print(c);
			if(max<c) {
				max=c;
			}
		}
		System.out.println("max是"+max);
		//bubbleSort(a);
		selectionSort(a,4);
		
	}
	//数组排序 
	public static void bubbleSort(int a[]) {
		for(int i=0;i<a.length-1;i++) {
			for(int j=0;j<a.length-1-i;j++) {
				if(a[j]>a[j+1]) {
					int temp=a[j+1];
					a[j+1]=a[j];
					a[j]=temp;
					
				}
				
			}
			
		}
		System.out.println(Arrays.toString(a));
	}
//二分查找 
	public static  void selectionSort(int b[],int key) {
		
		int low =0;
		int high=b.length-1;
		while(low<=high) {
			int mid= (low+high)/1;
			if(b[mid]==key) {
				System.out.println(mid);
				break;
			}else if(b[mid]<key) {
				low=mid+1;
				
			}else {
				high=mid-1;
				
			}
			
		}
		System.out.println("没有找到");
	}
}
